package com.kang.controller;

import com.kang.service.CatalogService;
import com.kang.service.ItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author 吃三明治派对中的康康
 * @Date 2022/4/25 19:50
 * @Version 1.0
 */
@Controller
public class IndexController {

    @Autowired
    CatalogService catalogService;

    @Autowired
    ItemsService itemsService;


    @RequestMapping("/")
    public String toIndex(){

        return "redirect:index";
    }


    @RequestMapping("/index")
    public String index(Model model){

        model.addAttribute("catalogs",catalogService.allCatalog());
        model.addAttribute("oneOfItems",catalogService.oneOfItems());
        model.addAttribute("indexItems",itemsService.indexGoods());

        return "index";
    }
}
